using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Indeco.G24.Web;
using Indeco.G24.Entities;
using Indeco.G24.Services;
using Indeco.G24.Data;

namespace Indeco.G24.Website.User
{
    public partial class Register : G24Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void createUserWizard_CreatingUser(object sender, LoginCancelEventArgs e)
        {
            
            NguoiDung nguoiDung = new NguoiDung();
            nguoiDung.IDNguoiDung = Guid.NewGuid();
            nguoiDung.TenSuDung = createUserWizard.UserName;
            nguoiDung.MatKhau = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(createUserWizard.Password, "MD5");
            nguoiDung.Email = createUserWizard.Email;
            nguoiDung.NgaySinh = DateTime.Now;
            nguoiDung.ThoiDiemCapNhat = DateTime.Now;
            nguoiDung.ThoiDiemChinhSua = DateTime.Now;
            nguoiDung.ThoiDiemThoat = DateTime.Now;
            nguoiDung.ThoiDiemTruyCap = DateTime.Now;
            NguoiDungService userService = new NguoiDungService();
            userService.Insert(nguoiDung);
            //DataRepository.NguoiDungProvider.Insert(nguoiDung);
           
        }

        protected void createUserWizard_ContinueButtonClick(object sender, EventArgs e)
        {
            Response.Redirect("~/");
        }

        protected void btnRegisterProvider_Click(object sender, EventArgs e)
        {
            createUserWizard.ActiveStepIndex = 2;
        }

        protected void btnUserFinish_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/User");
        }


    }
}
